package com.surprise.db.dao.join;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.surprise.db.dao.SimpleDAO;
import com.surprise.db.entity.join.SelectSurpriseLike002Entity;

/**
 * SelectSurpriseLike002.java
 * @author xuling
 * @since 2017年9月28日
 */
@Repository
public class SelectSurpriseLike002 extends SimpleDAO<SelectSurpriseLike002Entity> {

	/**
	 * 获得关注明细
	 * @return 关注明细
	 */
	public List<SelectSurpriseLike002Entity> select() {
		String sql = " SELECT surprise_shop.id as shopid, count(surprise_like.id) as count, surprise_like.showDate from surprise_like " +  
				" INNER JOIN surprise_product ON surprise_like.productid = surprise_product.id " +  
				" INNER JOIN surprise_shop ON surprise_product.surpriseShopId = surprise_shop.id " +  
				" AND (surprise_like.showDate BETWEEN surprise_shop.startTime and surprise_shop.endTime) " +  
				" GROUP BY surprise_like.showDate ORDER BY surprise_shop.id, surprise_like.showDate ASC ";
		return super.findBySql(sql);
	}
}
